///*
// * Licensed to the Apache Software Foundation (ASF) under one
// * or more contributor license agreements.  See the NOTICE file
// * distributed with this work for additional information
// * regarding copyright ownership.  The ASF licenses this file
// * to you under the Apache License, Version 2.0 (the
// * "License"); you may not use this file except in compliance
// * with the License.  You may obtain a copy of the License at
// *
// *     http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing,
// * software distributed under the License is distributed on an
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// * KIND, either express or implied.  See the License for the
// * specific language governing permissions and limitations
// * under the License.
// */
//package com.learn.framework.shiro.web.filter;
//
//import java.io.IOException;
//
//import javax.servlet.ServletRequest;
//import javax.servlet.ServletResponse;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//import org.apache.shiro.web.util.WebUtils;
//import com.learn.framework.enums.ErrorCodeEnum;
//import com.learn.framework.utils.RequestUtils;
//import com.learn.framework.utils.ResponseUtils;
//
///**
// * Filter that allows access to resources if the accessor is a known user, which is defined as
// * having a known principal.  This means that any user who is authenticated or remembered via a
// * 'remember me' feature will be allowed access from this filter.
// * <p/>
// * If the accessor is not a known user, then they will be redirected to the {@link #setLoginUrl(String) loginUrl}</p>
// *
// * @author Caratacus
// */
//public class UserFilter extends org.apache.shiro.web.filter.authc.UserFilter {
//
//    @Override
//    protected void redirectToLogin(ServletRequest request, ServletResponse response) throws IOException {
//        HttpServletRequest httpRequest = WebUtils.toHttp(request);
//        HttpServletResponse httpResponse = WebUtils.toHttp(response);
//        if (RequestUtils.isAjaxRequest(httpRequest)) {
//            httpResponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
//            ResponseUtils.sendFail(httpRequest, httpResponse, ErrorCodeEnum.UNAUTHORIZED);
//        } else {
//            String loginUrl = getLoginUrl();
//            WebUtils.issueRedirect(request, response, loginUrl);
//        }
//
//    }
//}
